<template>
  <div>
    <!-- 顶部导航栏 -->
    <header class="header">
      <div class="left">欢迎：{{ user?.username }}</div>
      <div class="nav-links">
        <a href="https://gitee.com/houer-er/vue-hou.git" target="_blank" rel="noopener noreferrer">
          <i class="fa fa-github"></i> Gitee仓库
        </a>
        <router-link to="/todo">Todolist</router-link>
        <router-link to="/screenshot">测试截图</router-link>
        
        <button @click="logout">退出</button>
      </div>
    </header>

    <!-- 主体内容 -->
    <main class="main-content">
      <router-view />
    </main>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { ref } from 'vue';

const router = useRouter()
const auth = useAuthStore()
const user = ref(auth.user); // 假设 auth 中有 user 对象包含 username

const logout = () => {
  auth.logout()
  router.push('/login')
}
</script>

<style scoped>
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  padding: 0 24px;
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin: 16px;
}

.left {
  font-size: 18px;
  font-weight: 500;
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-links a,
.nav-links router-link {
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  font-size: 16px;
  gap: 6px;
}

.nav-links a:hover,
.nav-links router-link:hover {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-links button {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-links button:hover {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.main-content {
  padding: 24px;
  margin: 0 16px 16px;
}
</style>
